<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        document.writeln("原数组为:3,6,81,4,0,7"+" ");
        // document需要写在script中才有意义
        ascending();
        function ascending(){
            var arr=[3,6,81,4,0,7];
            //打擂台法 依次找出最小的放最前
            for(var i=0;i<arr.length-1;i++){
                for(var j=i+1;j<arr.length;j++){
                    if(arr[i]>arr[j])
                    {
                        var tmp=arr[i];
                        // tmp用于交换
                        arr[i]=arr[j];
                        arr[j]=tmp;
                    }
                }
            }
            //提醒弹出框
            alert("升序数组："+arr);
            document.write("升序数组为:")
            //文本结果输出
            for(var i=0;i<arr.length;i++){
            if(i==arr.length-1){
                document.write(arr[i]);
                break;
            }
           document.write(arr[i]+",");    
    }
        } 
    </script>
</head>
<body>
    
</body>
</html>